Passkeys
Yeah I think this website is done. They haven't answered anyone in months.
It is because I really like devdojo but things like this happen when developers get greedy and don't want to pay for quality which is only $15/mo
I'm going to continue asking questions in case anyone shows up.
I have begun implementing passkeys myself and the instructions include to insert a snipper of code into app.js (entrypoint for code) to render the passkey javasacript. However, this file is compiled into the vite asset (app-XXXXXX.js) and is not included on auth pages. I found that there is an entrypoint supposedly for auth.js but I cannot figure out how to compile it into the build folder or use it properly. Any advice?
Is this in regards to the auth package by devdojo? I am going to assume yes lol:
Yes. With Vite, adding code to resources/js/app.js only helps on pages that actually include that Vite entry:
@vite(['resources/js/app.js'])
If the auth pages do not include app.js, then passkey JS will never run there, even though it compiled into app-xxxxx.js.
The clean fix is to make an auth-specific Vite entry.
In vite.config.js, add auth.js as an input:
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
'resources/js/auth.js',
],
refresh: true,
})
Then create/use:
resources/js/auth.js
Put the passkey snippet there.
Then include it only on auth pages/layout:
@vite(['resources/js/auth.js'])
or, if auth also needs CSS:
@vite([
'resources/css/app.css',
'resources/js/auth.js',
])
Then rebuild:
npm run build
Vite will generate the hashed file in public/build, and Laravel's @vite() will resolve the correct hashed asset from the manifest.
So the issue is not that auth.js can't compile. It just has to be registered as a Vite input and included by the Blade layout used by the auth pages.
I hope this helps somehow. That is what I would do.
Yes I did mean the devdojo auth package. This is very helpful and works as intended, thank you. I guess I was confused by the fact that in the partial blade components located at vendor/devdojo/auth/resources/views/includes/head.blade.php it has this line:
@if(config('devdojo.auth.settings.dev_mode'))
@vite(['packages/devdojo/auth/resources/css/auth.css', 'packages/devdojo/auth/resources/css/auth.js'])
@else
<script src="{{ asset('/auth/build/assets/scripts.js') }}"></script>
<link rel="stylesheet" href="{{ asset('/auth/build/assets/styles.css') }}" />
@endif
This means that the auth pages are already programmed to render custom js and css. However, the js file is blank and I don't really see a method to build your custom code into the built asset. Of course you don't want to edit the vendor file. In any case, I will use your method because it works.
